package com.self.common.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @version v1.0
 * @ClassName: RestTemplateConfig
 * @Description:
 * @Author: Mac
 * @Date: 2022/6/18 9:31
 */
@Configuration
public class RestTemplateConfig {

    @ConditionalOnMissingBean
    @Bean
    public RestTemplate restTemplate(){
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        requestFactory.setConnectTimeout(20000);
        requestFactory.setReadTimeout(10000);
        return new RestTemplate(requestFactory);
    }
}
